import {req_get_auth, req_post_auth} from "./axiosFun.js";
import {HOST} from '@/api/hosts'

export const getAllDrivers = (params) => {
    if (params===undefined)
        params = {}
    params.role = "S";
    const url = `${HOST}/users/page`;
    return req_get_auth("get", url, params);
};

export const addDriver = (data) => {
    if (data===undefined)
        data = {}
    data.roleWbxqy = "S";
    const url = `${HOST}/users`;
    return req_post_auth("post", url, data);
};

export const deleteDriver = (id) => {
    const url = `${HOST}/users/${id}`;
    return req_post_auth("delete", url);
};

export const updateDriver = (data) => {
    if (data===undefined)
        data = {}
    data.roleWbxqy = "S";
    const url = `${HOST}/users`;
    return req_post_auth("put", url, data);
};
export const listFreeDrivers = (params) => {
    const url = `${HOST}/driver/free-drivers`
    return req_get_auth("get", url, params)
}

export const getDriverDetail = (params) => {
    const url = `${HOST}/driver/detail`
    return req_get_auth("get", url, params)
}